<?php html::docType() ?>
<html>
<head>
	<?php html::head() ?>
	<!--  <link rel="stylesheet" type="text/css" href="../css/vic.css">-->
	<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div id="container">
		<?php html::navBar2() ?>
		<?php html::flash() ?>
		<div id="content">	 
			<div class="section" id="main">
				<div class="section-title">
					<h1 class="page-name">Beers </h1>
					<span class="title-sub"><a href="router.php?c=beer&a=create">Add a new beer</a></span>
				</div>
				<?php
					if(isset($view->request)){
						echo <<<HTML
						<div class="showing-results">
							<h2 class="showing-results">Showing results for Beer: "{$view->request['beer_name']}" and Country: "{$view->request['country_name']}"</h2>
						</div>
HTML;
					} 
					?>
				
				<div>
				<?php
					foreach($view->beers as $beer){
						$ratingElem = getRatingElement('beer', $beer['id'] ,$beer['rating']);
						echo <<<HTML
						<div class="beer-result">
							<div class="offer-venuename">
							<span class="venue-name">
								<a href=router.php?c=beer&a=view&id={$beer['id']}>{$beer['name']}</a>&nbsp;&nbsp;$ratingElem
							</span>
							</div>
							<div class="offer-description">
								<span class="offer-beers">
								A {$beer['type']['type']} from
								 {$beer['brewery']['country']['name']} made by
								  {$beer['brewery']['name']}
								</span>
								<span class="title-sub"><a href=router.php?c=beer&a=view&id={$beer['id']}>more info</a></span>
							</div>
						</div>
HTML;
					}
					?>
					<div class=pagination>
							<a href="<?php echo $view->prevPageLink ?>">Prev</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<?php echo $view->nextPageLink ?>">Next</a>&nbsp;&nbsp;
					</div>
				</div>
			</div>
		<div id="side">
			<div class="section" id="search">
				<div class="section-title">
					<h3>Search for a beer</h3>
				</div>
				<form action="router.php" method="GET" accept-charset="utf-8">
					<input type="text" id="beer-search" name="beer_name" value="BeerName">
					<select name="country_name" id="search-suburb">
						<option value="">Country</option>
						<?php
						foreach ($view->countries as $country) {
							echo "<option value=\"$country[name]\">$country[name]</option>";
						}?>
					</select>
					<input type="submit" id="search-button"value="Search" />
					<input type="hidden" name="c" value="beer" />
					<input type="hidden" name="a" value="find" />
				</form>
			</div>
		</div>
	</div>
	<?php html::footer2()?>
</div>
</body>
</html>
<!-- //	<div>A {$beer['id']} made by {$beer['brewery']['name']} from {$beer['brewery']['country']['name']}</div> -->